home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / alib10.zip / HYPER.ASM < prev    next >
Assembly Source File  |  1994-04-07  |  4KB  |  139 lines

  1. ;****************************  HYPER.ASM   **********************************
  2. PAGE  66,132
  3. comment 
  4.                              HYPER.ASM 
  5.                              ---------
  6.  
  7.      Purpose:
  8.      --------
  9.  
  10.      HYPER.ASM is intended to demonstrate a simple hyper database
  11.      which describes ALIB.LIB use.
  12.  
  13.      Using HYPER.ASM
  14.      ---------------
  15.  
  16.      The files HYPER.EXE and HYPER.DAT must be in the same directory.
  17.      HYPER is started by typing "HYPER"<cr> without any parameters.
  18.      
  19.  
  20.      Compiling
  21.      ---------
  22.  
  23.      HYPER.ASM was compiled using MASM and then linked with LINK.
  24.      
  25.      The following commands can be used:
  26.  
  27.         masm HYPER;
  28.         link HYPER,HYPER,,alib.lib;
  29.  
  30.      The file HYPER.DAT was built using EDREC.        
  31.  
  32. 
  33.  
  34.     include    mac.inc
  35.     include    common.inc
  36. ;-----------------------------------------------------------------------------
  37.     extrn    library_setup:far
  38.     extrn    library_terminate:far    
  39.     extrn    lib_error_handler:far
  40.     extrn    message:far
  41. ;------------------------------------------------------------------------------
  42. code        segment para public 'CODE'
  43.         assume    cs:code, ds:code
  44. ;-----------------------------------------------------------------------------
  45. ;
  46. filename    db    'HYPER.DAT',0
  47.  
  48. pspseg        dw    0            ;Program Segment Prefix
  49.         dw    200 dup (0)        ;stack
  50. stack_        dw    0
  51.  
  52. ;-----------------------------------------------------------------------------
  53. start:
  54.     cli
  55.     mov    cs:pspseg,es    ;save PSP segment
  56.     mov    ax,cs        ;get CODE segment
  57.     mov    ss,ax
  58.     mov    ds,ax
  59.     mov    es,ax
  60.     mov    sp,offset stack_
  61.     sti
  62.     
  63. ; next, release memory beyond the end of the program
  64. ; The  definition for ZSEG marks the
  65. ; end of the program's code, data and stack area.
  66. ; When linking be sure ZSEG is at the end of the program.
  67.  
  68.     mov    ax,zseg
  69.  
  70.     mov    bx,cs:pspseg        ;
  71.     mov    es,bx
  72.     sub    bx,ax
  73.     neg    bx            ; size of program in paragraphs
  74.     mov    ah,4Ah            ; resize memory block
  75.     int    21h
  76.  
  77.     mov    ax,cs
  78.     mov    es,ax
  79. ;
  80. ; check if enough memory free to run program
  81. ;
  82.     mov    ax,pspseg        ;pass psp segment to setup
  83.     mov    bx,8            ;number of floating point variables
  84.     call    library_setup
  85.     cmp    ax,128            ;check if 128k of memory is available
  86.     jae    got_enough_mem        ;jmp if 128k of memory avail
  87.     mov    al,7
  88.     mov    ah,fatal_return
  89.     call    lib_error_handler
  90.     jmp    exit2
  91.     
  92. got_enough_mem:
  93.     
  94. ; prevent an unintended program crash; trap Ctrl+Break, Ctrl+C and
  95. ; Ctrl+Alt+Del key combinations
  96.  
  97. ;    call    BREAK_KEY_INTERCEPT    ;optional
  98.  
  99.     mov    al,0            ;separator character for database
  100.     mov    bh,25            ;rows in display window
  101.     mov    bl,80            ;columns in display window
  102.     mov    cx,1            ;initial record#
  103.     mov    dx,0            ;window upper left corner
  104.     mov    si,offset filename
  105.     mov    bp,msg_hyper+msg_open+msg_close+msg_disp
  106.     call    message    
  107.     
  108.  
  109. ; normal program exit
  110. ;
  111. exit1:    
  112. ;
  113. ; de-activate the Ctrl+Break trap
  114. ;    call    BREAK_KEY_RESTORE    ;needed only if BREAK_KEY_INTERCEPT called
  115.  
  116. exit2:    mov    ax,0
  117.     call    library_terminate
  118.     mov    ax,4C00h
  119.     int    21h
  120. ;------------------------
  121. code        ends
  122. ;-------------------------------------------------------------------------
  123. ;
  124. ; This segment definition is needed so linker will put the LIBSEG here
  125. ; before the ZSEG.  We want ZSEG to be last so memory allocation will
  126. ; work correctly.
  127. ;
  128. LIBSEG           segment byte public 'LIB'
  129. LIBSEG    ENDS
  130. ;-------------------------------------------------------------------------
  131. ; zseg must be at the end of the program for memory allocation from
  132. ; DOS.
  133. ;
  134. zseg    segment    para public 'ZZ'
  135.  
  136. zseg    ends
  137.  
  138.         end    start
  139.